import time

import requests


# http://localhost:8080/jessica/
# http://39.106.152.15:8080/preview/
# http://39.106.152.15:8080/hdl/34020000001110000001/34020000001320000001.flv
# http://39.106.152.15:8080/hls/34020000001110000001/34020000001320000001.m3u8
class ReqM:
    def __init__(self):
        self.host = "http://39.106.152.15:8080/gb28181/api"

    def list(self):
        res = requests.get(f"{self.host}/list").json()
        print(res)

    def record_info(self):
        chan = "34020000001320000002"  # cam
        cid = "34020000001110000001"  # nvr
        url = f"{self.host}/records?id={cid}&channel={chan}"
        print (url)
        res = requests.get(url).text
        print(res)
    def bye(self):
        chan = "34020000001320000001"  # cam
        cid = "34020000001110000001"  # nvr
        url = f"{self.host}/bye?id={cid}&channel={chan}"
        print(url)
        res = requests.get(url).text
        print(res)
    def invite(self):
        chan = "34020000001320000001"  # cam
        cid = "34020000001110000001"  # nvr
        url = f"{self.host}/invite?id={cid}&channel={chan}"
        print(url)
        res = requests.get(url).text
        print(res)

    def invite_hist(self):
        chan = "34020000001320000001"  # cam
        cid = "34020000001110000001"  # nvr
        e=int(time.time())-600
        s=e-600

        url = f"{self.host}/invite?id={cid}&channel={chan}&startTime={s}&endTime={e}"
        print(url)
        res = requests.get(url).text
        print(res)


if __name__ == '__main__':
    g = ReqM()
    g.list()
    # g.bye()
    # g.invite_hist()

